package sample.stormax.pres.news.fragments;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import sample.stormax.pres.news.FeedbackActivity;
import sample.stormax.pres.news.R;
import sample.stormax.pres.news.utils.cache.CacheUtils;

public class SettingFragment extends Fragment {
    private static final String TAG = "SettingFragment";

    public SettingFragment() {
    }

    public static SettingFragment newInstance() {
        SettingFragment fragment = new SettingFragment();
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_setting, container, false);
        ButterKnife.bind(this,view);
        return view;
    }

    @Override
    public void onDetach() {
        super.onDetach();
    }



    @OnClick(R.id.habit_setting)
    void habitSetting() {
        Toast.makeText(getActivity(), "偏好设置", Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.delete_cache)
    void deleteCache() {
        Log.d(TAG,"delete Cache");
        CacheUtils cacheUtils = CacheUtils.newInstance(getActivity());
        cacheUtils.deleteDiskCache();
        Toast.makeText(getActivity(), "缓存已清理！", Toast.LENGTH_SHORT).show();

    }

    @OnClick(R.id.feedback)
    void feedBack() {
        Intent intent = new Intent(getActivity(), FeedbackActivity.class);
        getActivity().startActivity(intent);
//        Toast.makeText(getActivity(), "意见反馈", Toast.LENGTH_SHORT).show();
    }

    @OnClick(R.id.about)
    void about() {
        Toast.makeText(getActivity(), "我们是8组！", Toast.LENGTH_SHORT).show();
    }

}
